/*
 * @Author: your name
 * @Date: 2021-06-01 14:10:20
 * @LastEditTime: 2021-06-03 14:41:47
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \bazai_island_api\core\mysqlDB.js
 */
const Sequelize = require('sequelize')
const {
    dbName,
    host,
    port,
    user,
    password
} = require('../config/config').database
const sequelize = new Sequelize(dbName, user, password, {
    dialect: 'mysql',
    host,
    port,
    logging: true,
    timezone: '+08:00',
    define: {
        // create_time update_time 
        timestamps: true,
        // delete_time
        paranoid: true,
        createdAt: 'created_at',
        updatedAt: 'updated_at',
        deletedAt: 'deleted_at',
        // 修改驼峰命名规范
        underscored: true,
        freezeTableName: true,
        // 过滤返回字段
        scopes: {
            bh:{
                attributes: {
                    exclude: ['updated_at', 'deleted_at', 'created_at']
                }
            }
        }
    }
})

sequelize.sync({
    force: false
})

module.exports = {
    sequelize
}